#include "stdafx.h"
#include "MyIExampleEvts.h"
#include "MyConnectionPointContainer.h"

HRESULT STDMETHODCALLTYPE MyConnectionPointContainer::QueryInterface(REFIID riid, void **ppv)
{
    MyIExampleEvts *p = CONTAINING_RECORD(this, MyIExampleEvts, container);
    return p->example.QueryInterface(riid, ppv);
}

ULONG STDMETHODCALLTYPE MyConnectionPointContainer::AddRef()
{
    MyIExampleEvts *p = CONTAINING_RECORD(this, MyIExampleEvts, container);
    return p->example.AddRef();
}

ULONG STDMETHODCALLTYPE MyConnectionPointContainer::Release()
{
    MyIExampleEvts *p = CONTAINING_RECORD(this, MyIExampleEvts, container);
    return p->example.Release();
}

HRESULT STDMETHODCALLTYPE MyConnectionPointContainer::EnumConnectionPoints(IEnumConnectionPoints **ppEnum)
{
    *ppEnum = NULL;
    return E_NOTIMPL;
}

HRESULT STDMETHODCALLTYPE MyConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)
{
    MyIExampleEvts *p = CONTAINING_RECORD(this, MyIExampleEvts, container);
    if (IsEqualIID(riid, DIID_IFeedback))
    {
        *ppCP = &p->point;
        p->point.AddRef();
    }
    else if (IsEqualIID(riid, DIID_ICompare))
    {
        *ppCP = &p->point2;
        p->point2.AddRef();
    }
    else
    {
        *ppCP = NULL;
        return E_NOINTERFACE;
    }
    return S_OK;
}
